package com.mlx.mylogin.inter;


import com.mlx.mylogin.base.HttpSnapshot;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public interface LoginManager {

    /**
     * 颁发token，用在登录成功后颁发token
     * @param user 用户信息
     * @return token信息
     */
    String issueToken(Object user);

    /**
     * 身份认证
     *
     * @param httpSnapshot http快照
     */
    void identityAuthentication(HttpSnapshot httpSnapshot);

    /**
     * 移除token，一般用于登出
     */
    void removeToken();

    /**
     * 获取Http请求对象
     */
    HttpServletRequest getRequest();

    /**
     * 获取Http响应对象
     */
    HttpServletResponse getResponse();


    HttpSession getSession();

    /**
     * http请求路径
     */
    String getServletPath();

    /**
     * 获取用户
     *
     */
    Object getUser();

    default <T> T getUser(Class<T> userClass){
        return (T) getUser();
    }
}
